<?php
/**
 * Created by PhpStorm.
 * User: shnaider
 * Date: 20.01.2015
 * Time: 20:03
 */

class core_controllers_ajax extends basecontroller
{
    function index()
    {
        if (isset($_GET['action'])) {
            $action = security::input_cut_filter($_GET['action']);
            switch ($action) {
                case 'CallBack':
                    self::call_back();
                    break;
                default:
                    exit;
            }
        }
    }
public static function call_back(){

        $name = DB::escape($_POST['name']);
        $email = DB::escape($_POST['email']);
        $tel = DB::escape($_POST['tel']);
    if ((!empty($name)) AND (!empty($tel)) AND (!empty($email))) {

        $sql = "INSERT INTO zayavka (Zname,Zemail,Ztelephone,Zstatus)
            VALUES('$name','$email','$tel','new')";

        if (DB::query($sql)) {
            echo json_encode(1);
            exit;
        }
        else {
            echo json_encode(3);
            exit;
        }
    }
    else {
        echo json_encode(2);
        exit;
    }
}
}